package cn.buk.tms.dto;

import cn.buk.tms.entity.misc.VehicleGroupInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.beans.BeanUtils;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 车型组信息DTO
 *
 * @author yfdai
 */
public class VehicleGroupInfoDto {

  private int id;

  private int enterpriseId;

  /**
   * 名称
   */
  @NotNull
  @Size(min = 2)
  private String name;

  private int level;

  private String remark;

  private List<VehicleGroupMappingDto> mappings;

  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Date createTime;

  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Date lastUpdate;

  public static VehicleGroupInfo convertTo(VehicleGroupInfoDto dto) {
    VehicleGroupInfo obj = new VehicleGroupInfo();
    BeanUtils.copyProperties(dto, obj);

    return obj;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public int getEnterpriseId() {
    return enterpriseId;
  }

  public void setEnterpriseId(int enterpriseId) {
    this.enterpriseId = enterpriseId;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Date getCreateTime() {
    return createTime;
  }

  public void setCreateTime(Date createTime) {
    this.createTime = createTime;
  }

  public Date getLastUpdate() {
    return lastUpdate;
  }

  public void setLastUpdate(Date lastUpdate) {
    this.lastUpdate = lastUpdate;
  }

  public String getRemark() {
    return remark;
  }

  public void setRemark(String remark) {
    this.remark = remark;
  }

  public List<VehicleGroupMappingDto> getMappings() {
    if (mappings == null) {
      mappings = new ArrayList<>();
    }
    return mappings;
  }

  public void setMappings(List<VehicleGroupMappingDto> mappings) {
    this.mappings = mappings;
  }

  public int getLevel() {
    return level;
  }

  public void setLevel(int level) {
    this.level = level;
  }
}
